function love.load()
    border={
        400,100,
        love.graphics.getWidth()-100,100,
        love.graphics.getWidth()-100,love.graphics.getHeight()-100,
        400,love.graphics.getHeight()-100,
        400,100
    }
    colors={
        blue = {0,0,1,1},
        red = {1,0,0,1},
        green ={ 0,1,0,1},
        darkGrey={0.3,0.3,0.3,1},
        white={1,1,1,1},
        pink={1,192/255,203/255,1}
    }
end

function SwitchScence (scence)
    -- 将重要的函数赋予空值，以免冲突
    love.update = nil
    love.draw = nil
    love.keypressed = nil
    -- 将需要的场景加载进来，并执行load函数
    love.filesystem.load (scence..".lua") ()
end



font_a=love.graphics.newFont(80)
font_b=love.graphics.newFont(55)

local function new_object(x, y, size, color)
    local object = {
        x = x,
        y = y,
        size = size,
        color = color,
    }
    function object:move(vx, vy)
        self.x = self.x + (vx or 0)
        if self.x>love.graphics.getWidth()-100 or self.x<400 then
            self.x=self.x-vx
        end
        self.y = self.y + (vy or 0)
        if self.y>love.graphics.getHeight()-100 or self.y<100 then
            self.y=self.y-vy
        end
    end

    function object:draw()
        love.graphics.setColor(self.color)
        love.graphics.circle("fill", self.x, self.y, self.size)
        love.graphics.setColor(1,1,1,1)
    end

    return object
end

local player = new_object(400, 100, 10, {1, 1, 1, 1})
local move_speed = 150

function love.update(dt)
    local vx, vy = 0, 0

    if love.keyboard.isDown("w") then
        vy = -move_speed*dt
    end
    if love.keyboard.isDown("a") then
        vx = -move_speed*dt
    end
    if love.keyboard.isDown("s") then
        vy = move_speed*dt
    end
    if love.keyboard.isDown("d") then
        vx = move_speed*dt
    end

    player:move(vx, vy)
end

function love.mousepressed(xp,yp,bp)
    if 100<xp and xp<300 and bp==1 then
        if 100<yp and yp<200 then
            SwitchScence ("changepink")
            elseif 400<yp and yp<500 then
                SwitchScence ("exitpink")
        end
    end
end

function love.draw()
    love.graphics.setColor(colors.blue)--最大蓝框
    love.graphics.rectangle("fill",0,0,love.graphics.getWidth(),love.graphics.getHeight())

    x,y= love.mouse.getPosition()
    if 100<x and x<300 and ( (100<y and y<200) or (400<y and y<500)) then
        if 100<y and y<200 then
            love.graphics.setColor(colors.darkGrey)--按钮红框，上
            love.graphics.rectangle("fill",100,100,200,100)
            love.graphics.setColor(colors.red)--按钮红框，下
            love.graphics.rectangle("fill",100,400,200,100)
        else
            love.graphics.setColor(colors.red)--按钮红框，上
            love.graphics.rectangle("fill",100,100,200,100)
            love.graphics.setColor(colors.darkGrey)--按钮红框，下
            love.graphics.rectangle("fill",100,400,200,100)
        end
        else
            love.graphics.setColor(colors.red)--按钮红框，上
            love.graphics.rectangle("fill",100,100,200,100)
        
            love.graphics.setColor(colors.red)--按钮红框，下
            love.graphics.rectangle("fill",100,400,200,100)
    end

    love.graphics.setColor(colors.pink)--点移动填充框
    love.graphics.rectangle("fill",400,100,300,400)

    love.graphics.setColor(colors.white)--点移动白框
	love.graphics.line(border)

    love.graphics.setFont(font_b)--change与exit的位置
    love.graphics.print("change",100,120)
    love.graphics.setFont(font_a)
    love.graphics.print("EXIT",110,405)

    player:draw()
end